package com.wpp.concurrent.demo5;

/**
 * @description:
 * @author: WangPengPeng
 * @create: 2022-01-23 21:16
 **/
public class Demo5Client3 {

    public static void main(String[] args) throws InterruptedException{
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {

                }
            }
        });
        thread.start();

        // 设置中断位
        thread.interrupt();
        System.out.println("isInterrupted: " + thread.isInterrupted());
        System.out.println("main isInterrupted: " + Thread.currentThread().isInterrupted());

        // 虽然调用者是thread 但实际上 static修饰的 获取的是主线程的中断状态
        System.out.println("isInterrupted: ----" + thread.interrupted());
        Thread.currentThread().interrupt();
        System.out.println("main isInterrupted: " + Thread.currentThread().isInterrupted());
        System.out.println("isInterrupted: -----" + Thread.interrupted());
        System.out.println("main isInterrupted: " + Thread.currentThread().isInterrupted());


        System.out.println("isInterrupted: " + thread.isInterrupted());
        thread.join();
        System.out.println("main is over");

    }
}
